﻿using System.Data;

namespace DAL
{
    public static class DalTypeContract
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetTypeContract(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_TypeContract_Get");
        }
        public static DataTable GetTypeContractEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@TypeContract_ID", id);
            return Cls.GetData("sp_TypeContract_Get_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtTypeContract obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@TypeContract_Code", obj.TypeContract_Code);
            Cls.AddParameter("@TypeContract_Name", obj.TypeContract_Name);
            Cls.AddParameter("@TypeContract_Node", obj.TypeContract_Node);
            return Cls.ExecuteNonQuery("sp_TypeContract_Insert");
        }
        public static bool Update(EtTypeContract obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@TypeContract_ID", obj.TypeContract_ID);
            Cls.AddParameter("@TypeContract_Code", obj.TypeContract_Code);
            Cls.AddParameter("@TypeContract_Name", obj.TypeContract_Name);
            Cls.AddParameter("@TypeContract_Node", obj.TypeContract_Node);
            return Cls.ExecuteNonQuery("sp_TypeContract_Update");
        }
        public static bool Delete(EtTypeContract obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@TypeContract_ID", obj.TypeContract_ID);
            obj.Msg = Cls.ExecuteNonQueryOutput("sp_TypeContract_Delete", "@Msg");
            return true;
        }
        #endregion
    }

    public class EtTypeContract
    {
        public int TypeContract_ID { get; set; }
        public string TypeContract_Code { get; set; }
        public string TypeContract_Name { get; set; }
        public string TypeContract_Node { get; set; }
        public int Msg { get; set; }
    }
}